clc; clear; close all;
load('intermediate\CompileAllCIPCalcs.mat');
addpath('figures', 'functions')

%% Set figure options

optfig.fontname     = 'Times New Roman';
optfig.dimension    = [0 0 8 6];
optfig.lw           = 1;
optfig.folder       = 'output\Main\';
optfig.color        = num2cell(parula(7),2);
% optfig.color      = num2cell(jet(7),2);
optfig.style        = {'-','--',':','-.','-','--','-',};
optfig.marker       = {'none','o','x','s','+'};
optfig.markersize   = 10;

optfig.fontsize_tit = 17;
optfig.fontsize_ax  = 17; %46
optfig.fontsize_lab = 13;
optfig.fontsize_leg = 13;

optfig.plotfig = 1; % If 1, plots figures

%% Create figures

welfareSubset = WelfareArbs(:,[1 3 5 7 9 11]);
%Plots the price impact coefficient (alphas) by day
fig_FX_futures_price_impact(datesExtras, selectorNonHolidays, coeffs, optfig)

%Plots the cross-currency basis for all five currencies
fig_CIP_history(dateVecCIP2, CIPCalcsAll, optfig)

%Plots the welfare gains to arbitrage for all 5 currencies over the period
%for which we have microstructure estimates (late 2019-early 2021)
fig_CIP_welfare(datesExtras, selectorNonHolidays, WelfareArbs, optfig)
fig_CIP_welfareGDPRobust(datesExtras, selectorNonHolidays, WelfareArbs, optfig)
fig_CIP_welfareDailyVolumeRobust(datesExtras, selectorNonHolidays, WelfareArbs, optfig)

%Plots the gap-closing trade size for all currencies for the recent period
%for which we have microstructure data
fig_CIP_arbsize(datesExtras, selectorNonHolidays, WelfareArbs, optfig)
fig_CIP_arbsizeGDPRobust(datesExtras, selectorNonHolidays, WelfareArbs, optfig)
fig_CIP_arbsizeDailyVolumeRobust(datesExtras, selectorNonHolidays, WelfareArbs, optfig)

%Plots welfare gains to arbitrage for all currencies going back to 2010
%using composite estimates from recent period for price impact
fig_CIP_welfare_history_2010(CIPAllS1, WelfareArbs2, optfig)


%Plots surface of alpha coefficients, cross-market price impact
%assumptions, and cross-currency bases required to generate $10B in welfare
%losses
load('input\Figure11Workspace.mat')
fig_surface_plots(alphaGrid, crossMarketGrid, CCBEuro, optfig)

%Generates price impact curves that show $ trade size versus percent (in
%percent, so 1.0 is 1%) for each currency
fig_price_impact_curves(valsForSumStats2, alphas, Multipliers, TickSizes, optfig)

%GeneratesScatterplots

for (counter=1:5)
    fig_CIP_ccbVSalphasScatter(CIPCalcsAll,coeffs,counter,optfig)
    fig_CIP_ccbVSWelfareScatter(CIPCalcsAll,welfareSubset,counter,optfig)
end
